import { IFeidaoAiNodejsComponent } from '@dfeidao/atom-nodejs/interfaces';
import nodejs from '@dfeidao/atom-nodejs/msg/nodejs';
import render from '@dfeidao/atom-nodejs/render/render';
// tslint:disable-next-line: ordered-imports
import format from '@dfeidao/atom-web/dt/format';
import set from '@dfeidao/atom-web/global/set';
import p001 from './p001';
import p003 from './p003';

export default async function na001(fd: IFeidaoAiNodejsComponent) {
	// todo
	const ret = await nodejs<{dt1: Array<{exam_name: string;start_time: number;
		examination_category: string;exam_time: string;exam_score: string;
		finish_time: number}>,t: number}>(fd.data.actionid,fd.data.sessionid,'examination-management/zj-000001/s001',
		{filter:{page_no:1}});
	const ren = ret.dt1.map((n) => {
		return {...n,start_time:format(n.start_time,2),finish_time:format(n.finish_time,2)};
	});
	// console.log('ren:',ren);
	// console.log(ret);
	// const p = ret.dt1.map((n) => {
	// 	return n.examination_category;
	// });
	render(fd.data.node,ren,p001,'p001');

	if (ret.t > 20) {
		render(fd.data.node,ret.t,p003,'p003');
	}
	set('flag',1);
}
